package Eyjafjalla.card.attack;

import Eyjafjalla.action.ChooseHandToCloudAction;
import Eyjafjalla.action.EyjafjallaAttackAction;
import Eyjafjalla.action.MakeTempCardInCloudAction;
import Eyjafjalla.card.AbstractEyjafjallaCard;
import Eyjafjalla.helper.StringHelper;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.actions.common.ApplyPowerAction;
import com.megacrit.cardcrawl.actions.common.AttackDamageRandomEnemyAction;
import com.megacrit.cardcrawl.actions.common.DamageAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.localization.CardStrings;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.powers.watcher.VigorPower;

public class Volcano_Eyjafjalla extends AbstractEyjafjallaCard {
    public static final String ID = "Volcano_Eyjafjalla";
    private static final CardStrings cardStrings;

    public Volcano_Eyjafjalla(){
        super(ID, cardStrings.NAME,3,cardStrings.DESCRIPTION,CardType.ATTACK,CardRarity.RARE,CardTarget.ALL_ENEMY);
        this.baseDamage = 6;
        this.damage =6;
        this.baseMagicNumber = 5;
        this.magicNumber = 5;
        this.exhaust = true;
        setFireDescription(cardStrings.EXTENDED_DESCRIPTION[1]);
    }


    @Override
    public void renderCardPreview(SpriteBatch sb) {
        if(this.baseMagicNumber>1)
            super.renderCardPreview(sb);
    }

    @Override
    public AbstractCard makeCopy() {
        return new Volcano_Eyjafjalla();
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        addToBot(new EyjafjallaAttackAction());
        for(int i =0;i<this.baseMagicNumber;i++){
            addToBot(new AttackDamageRandomEnemyAction(this, AbstractGameAction.AttackEffect.FIRE));
        }
        if(this.baseMagicNumber>1)
            addToBot(new MakeTempCardInCloudAction(getCopyCard()));
        if(isFire()){
            addToBot(new ApplyPowerAction(p,p,new VigorPower(p,2),2));
        }
    }

    private AbstractCard getCopyCard(){
        AbstractCard v = this.makeStatEquivalentCopy();
        v.baseMagicNumber = this.baseMagicNumber-1;
        v.magicNumber =v.baseMagicNumber;
        v.updateCost(-1);
        return v;
    }

    @Override
    public void upgrade() {
        if(!this.upgraded){
            upgradeName();
            upgradeMagicNumber(1);
        }
    }

    static {
        cardStrings = CardCrawlGame.languagePack.getCardStrings(ID);
    }
}

